This repository contains a series of templates for creating HTML and PDF documents in rmarkdown using the style themes employed by NZ Department of Conservation (DOC).
In order for PDF output to work you need to make sure you have a LATEX distribution installed. MIKTEX is the most common distribution to use.
First off install the devtools package if you haven’t already.
install.packages("devtools")
Now install the DocRR package using devtools::install_github('ogansell/DocRR').
RStudio supports these templates natively.
If using RStudio you can now load pre-made templates for outputting analysis and reporting in HTML or PDF format. To do this go to File>New File and select ‘RMarkdown’
From here you can now load any one of the templates by selecting RMarkdown>From Template and selecting any one of the templates under ‘DocRR’.
Select the template you want to load, give it a name and save it.
Important to note here is that when you save your file a folder structure for your file is automatically made. This is because the templates have some extra files they are dependant on in order to compile.
You’ve now got a template for producing a pdf report to begin working on. Press the knit button to have a look at what it produces.
When making HTML pages a common intermediate step is to ‘knit’ your document to ‘.docx’ format. This makes it easy to send to reviewers to get their input. The webshot is useful in this instance as it includes a screenshot of any htmlwidgets used in the knitted .docx file. It require installation of the PhantomJS software. This causes installation of the DocRR package to fail on older installations of R so it is recommended to install this manually after installing DocRR. Do this by running the code webshot::install_phantomjs().
If you’re not using RStudio it’s still easy to use these templates.
Wrapper functions have been made to make it easy to load a template.
There is one function for each template:
DocRR::article("myarticle.Rmd") DocRR::article_book("myarticle.Rmd") DocRR::report("myreport.Rmd") DocRR::report_book("myreport.Rmd") DocRR::plain_html("myplainwebpage.Rmd") DocRR::tab_html("mytabbedwebpage.Rmd") DocRR::indicator_html("myindicatorfactsheet.Rmd")
To compile your document use rmarkdown::render("my_article/my_article.Rmd"). Remember that you need to point it to the right directory.
You can now start making documents using these templates. It’s important to remember that each template has been designed for a specific output (i.e. pdf articles or reports, plain webpages, web pages with tabbed layout or standardised pages for reporting on biodiversity indicators). Therefore the docarticle or docreport templates won’t work for making webpages and web templates won’t work for generating pdf’s. Saying that, all of the templates will output to .docx (word format) provided some of the yaml metadata is altered (we’ll cover this later). This is useful for giving reviewers who aren’t familiar with R or rmarkdown a version of your document for editing and making comments.
The templates in this package have all of the style elements needed to adjust the colour of banners or fonts according to the DOC style guidelines.
Functions have been defined to allow the user to easily choose whatever colour is required for banners and fonts in both web and pdf output.
The banners and font colours are:
| Colours | Functions | |||
|---|---|---|---|---|
| Banners | Font | |||
| PDF Article | PDF Report | Web banner | Web font | |
Alpine |
DocRR::Alpine
|
DocRR::Alpine_report
|
DocRR::Alpine_web
|
DocRR::font_Alpine
|
Lake |
DocRR::Lake
|
DocRR::Lake_report
|
DocRR::Lake_web
|
DocRR::font_Lake
|
Sunset |
DocRR::Sunset
|
DocRR::Sunset_report
|
DocRR::Sunset_web
|
DocRR::font_Sunset
|
Fauna |
DocRR::Fauna
|
DocRR::Fauna_report
|
DocRR::Fauna_web
|
DocRR::font_Fauna
|
Kiwi |
DocRR::Kiwi
|
DocRR::Kiwi_report
|
DocRR::Kiwi_web
|
DocRR::font_Kiwi
|
Honey |
DocRR::Honey
|
DocRR::Honey_report
|
DocRR::Honey_web
|
DocRR::font_Honey
|
Greyscale |
DocRR::Greyscale
|
DocRR::Greyscale_report
|
DocRR::Greyscale_web
|
DocRR::font_Greyscale
|